﻿using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NTmdb.TestProject
{
    /// <summary>
    ///     This is a test class for TmdbWatchListRequestTest and is intended
    ///     to contain all TmdbWatchListRequestTest Unit Tests
    /// </summary>
    [TestClass]
    public class TmdbWatchListRequestTest
    {
        /// <summary>
        ///     A test for TmdbWatchListRequest Constructor
        /// </summary>
        [TestMethod]
        public void TmdbWatchListRequestConstructorTest()
        {
            var target = new TmdbWatchListRequest();
            Assert.IsNotNull( target );
        }

        /// <summary>
        ///     A test for AddToWatchList
        /// </summary>
        [TestMethod]
        public void AddToWatchListTest()
        {
            var target = new TmdbWatchListRequest();
            bool expected = new Random().Next( 0, Int32.MaxValue ) % 2 == 0;
            target.AddToWatchList = expected;
            bool actual = target.AddToWatchList;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Id
        /// </summary>
        [TestMethod]
        public void IdTest()
        {
            var target = new TmdbWatchListRequest();
            int expected = new Random().Next( 0, Int32.MaxValue );
            target.Id = expected;
            int actual = target.Id;
            Assert.AreEqual( expected, actual );
        }

        /// <summary>
        ///     A test for Serialize & Deserialize
        /// </summary>
        [TestMethod]
        public async Task SerializeDeserializeTest()
        {
            var target = new TmdbWatchListRequest()
            {
                Id = new Random().Next(0, Int32.MaxValue),
                AddToWatchList = new Random().Next(0, Int32.MaxValue) % 2 == 0
            };
            var json = await target.Serialize();
            Assert.AreEqual(String.Format("{0}\"movie_id\":{1},\"movie_watchlist\":{2}{3}", "{", target.Id, target.AddToWatchList.ToString().ToLower(), "}"), json);
            var actual = await target.DeserializeJson<TmdbWatchListRequest>(json);

            Assert.AreEqual(target.Id, actual.Id);
            Assert.AreEqual(target.AddToWatchList, actual.AddToWatchList);
        }
    }
}